﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace DEMO_TEMP1.Retrieval
{
    public partial class ConfirmeRetrieval : UserControl
    {
        DataSet ds = new DataSet();
        //DataSet dl = new DataSet();
        public WebPor.Service1 lc = new WebPor.Service1();
        string userid ,location,mawb_no,piece,slipid ;
        int indexconfirm = 0;
        public ConfirmeRetrieval(string user,DataSet data,int index)
        {
            InitializeComponent();
            userid = user;
            if (data==null)
            {
                MessageBox.Show("data error");
            }
            else
            {
                ds = data;
                indexconfirm = index;
                // mawb_no = ds.Tables[0].Rows[index]["display_mawb"].ToString();
                // lc.Url = string.Format("http://192.168.1.220/WebAppPor01/Service1.asmx");
                // dl= lc.GetLocationHis(mawb_no);
                Setdata(ds, indexconfirm);
            }
            
          

        }

        private void Setdata(DataSet dl, int indexconfirm)
        {

           // MessageBox.Show(dl.Tables[0].Rows.Count.ToString());
            //user ="";
            location=dl.Tables[0].Rows[indexconfirm]["location"].ToString();
            mawb_no=dl.Tables[0].Rows[indexconfirm]["display_mawb"].ToString();
            mawb_no = mawb_no.Substring(0, 3) + mawb_no.Substring(4, mawb_no.Length - mawb_no.Substring(0, 4).Length);
            piece=dl.Tables[0].Rows[indexconfirm]["piece_count"].ToString();
            slipid=dl.Tables[0].Rows[indexconfirm]["slip_id"].ToString();
            label5.Text = mawb_no;
            label6.Text = location;
            label7.Text = piece;
        }

       

        private void ConfirmeRetrieval_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            // int store= Convert.ToInt32(storepcs);
            //int total = Convert.ToInt32(ds.Tables[0].Rows[index]["total_piece_count"]);
            //int store = Convert.ToInt32(ds.Tables[0].Rows[index]["stored_piece_count"]);
            //int bal = total - store;
            //int sto = Convert.ToInt32(storepcs);
            if (true)
            {
                CallRetrievUpdate(userid, location, mawb_no, piece, slipid);


            }
            else
            {
                CallRetrievUpdate(userid, location, mawb_no, piece, slipid);

            }



            ///////////////////
           
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form4 f4 = new Form4(userid,ds, indexconfirm);
            f4.Show();
        }
        DataSet usp_HHTRetreiveCargo = new DataSet();
        private void CallRetrievUpdate(string userid, string l, string mawbNodet, string p, string slipid)
        {
            string status, mes = "";

            lc.Url = String.Format("http://192.168.1.220/WebAppPor01/Service1.asmx");
            usp_HHTRetreiveCargo = lc.usp_HHTRetreiveCargo(userid, l, mawbNodet, p, slipid);
            status = usp_HHTRetreiveCargo.Tables[0].Rows[0]["vchStatus"].ToString();
            mes = usp_HHTRetreiveCargo.Tables[0].Rows[0]["vchMessage"].ToString();
            if (status == "PASS")
            {

                Form2 f2 = new Form2(userid);
                f2.Show();

            }
            else
            {
                MessageBox.Show(mes);
            }
        }

    }
}
